﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Public;
using System.Windows.Forms;

namespace DAL
{
    class clsKetNoi
    {
        SqlConnection connect = new SqlConnection();
        public clsKetNoi()
        {
            connect.ConnectionString = "Server=VAIO-E\\CNServer;Database=QUANLYSACH;User Id=sa ;Password=congnhan;";
            if (connect.State == ConnectionState.Closed)
            {
                try
                {
                    connect.Open();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        public DataTable clsLayDuLieu(string sql)
        {
            SqlCommand command = new SqlCommand(sql,connect);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            return dt;
        }
    }
}
